package or.exa.cangguan.service.impl;

import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import or.exa.cangguan.common.Page;
import or.exa.cangguan.entity.dto.UserInfoDto;
import or.exa.cangguan.entity.vo.UserInfoVo;
import or.exa.cangguan.mapper.UserInfoMapper;
import or.exa.cangguan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public Page getUserList(UserInfoVo userInfoVo) {
        log.info("userInfoVo:"+ userInfoVo);
        Page page = new Page();
        BeanUtil.copyProperties(userInfoVo, page);
        log.info("page:{}",page);
        List<UserInfoDto> userInfoDtos = userInfoMapper.selectInfo(userInfoVo, page);
        log.info("userInfoDtos:"+ userInfoDtos);
        page.setResultList(userInfoDtos);
        Integer count = userInfoMapper.selectInfoCount(userInfoVo);
        page.setTotalNum(count);
        log.info("page:"+ page);



        return page;
    }
}
